package net.kleinhenz.questor.model;

import java.util.ArrayList;
import java.util.List;

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.core.Commit;

public class Station implements MediaContainer {
	
	@Attribute(name="stationid", required=true)
	private int id = -1;

	@Attribute(required=false, name="autoid")
	private int autoId = -1;

	@Attribute(required=false)
	private boolean end = false;

	@ElementList(required=false)
	private List<Media> multimedia = new ArrayList<Media>();

	@ElementList(required=false, inline=true)
	private List<Content> content = new ArrayList<Content>();
	
	@Element(required=false)
	private Battle battle = null;
	
	private List<Choice> choices = new ArrayList<Choice>();
	
	public int getAutoId() {
		return autoId;
	}

	public void setAutoId(int autoId) {
		this.autoId = autoId;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public List<Media> getMultimedia() {
		return multimedia;
	}

	public void setMultimedia(List<Media> multimedia) {
		this.multimedia = multimedia;
	}

	public List<Choice> getChoices() {
		return choices;
	}

	public void addChoice(Choice choice) {
		this.choices.add(choice);
	}

	public List<Content> getContents() {
		return content;
	}
	
	public void setContents(List<Content> contents) {
		this.content = contents;
	}

	public void setBattle(Battle battle) {
		this.battle = battle;
	}

	public Battle getBattle() {
		return battle;
	}

	public void setEnd(boolean end) {
		this.end = end;
	}

	public boolean isEnd() {
		return end;
	}
	
	@Commit
	public void aggregateChoices() {
		for (Content c : getContents()) {
			getChoices().addAll(c.getChoices());
		}
	}
}
